package table.creators;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import controllers.AuthorHelper;
import models.Violation_record;
import models.Driver;
import models.Vehicle;
import controllers.Helper;
import controllers.TableModel;
import controllers.TableModel.AoColum;

public class Violation_recordTable {

    public static TableModel create(String current_user) {
        final String VIOLATION_RECEIPE = "|电子抄报|现场处罚单据";
        final String PROCESS_TYPE = "|告诫单|口头教育|违纪单|停驾整改";
    
        final String title = "违章记录";
        String today = Helper.dateToString(new Date());
        String now = Helper.datetimeToString(new Date());

        List<AoColum> colums = new ArrayList<AoColum>();
        TableModel model = new TableModel();

        //                           name,             title,         required,     defaut,        cansearch, editable,    edit_type,    edit_data,            editable_settings    
        if(true) {
           colums.add(model.new AoColum("id",    "编号",    false,    "",    false,    false,    "select",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("driver.name",    "司机",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Driver.getNameJson(),    null,  "ONEBOX",  "driver",  "name",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("vehicle.plate_number",    "车号",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Vehicle.getPlate_numberJson(),    null,  "ONEBOX",  "vehicle",  "plate_number",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("violation_date",    "违章日期",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "date",    null,    null,  "TWOBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("violation_receipe",    "违规违法处罚单据",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Helper.getSelectOptionJson(VIOLATION_RECEIPE),    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("violation_content",    "违规违法内容",    true,    "",    false,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("violation_place",    "违规地点",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "edit",    null,    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        if(AuthorHelper.isInRoleGroup(current_user, "0")) {
           colums.add(model.new AoColum("process_type",    "处理形式",    true,    "",    true,    AuthorHelper.isInRoleGroup(current_user, "0"),    "select",    Helper.getSelectOptionJson(PROCESS_TYPE),    null,  "ONEBOX",  "",  "",  "",   "",   "",   "",  false));
        }
        model.buildModel(Violation_record.class, 600, title, AuthorHelper.canDo(current_user, title, "增加"), AuthorHelper.canDo(current_user, title, "搜索"), AuthorHelper.canDo(current_user, title, "删除"), colums);
        return model;
    }
}

